/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package berlin.volders.rxdiff2;

import ohos.utils.Parcel;
import ohos.utils.Sequenceable;

/**
 * Thing.
 *
 * @since 2021-06-29
 */
public class Thing implements Sequenceable {
    private int id;
    private String text;
    private int color;

    private Thing() {
    }

    private Thing(int id, String text, int color) {
        this.id = id;
        this.text = text;
        this.color = color;
    }

    /**
     * builder
     *
     * @return Builder
     */
    public static Builder builder() {
        return new Builder();
    }

    @Override
    public boolean marshalling(Parcel parcel) {
        return parcel.writeInt(id) && parcel.writeString(text) && parcel.writeInt(color);
    }

    @Override
    public boolean unmarshalling(Parcel parcel) {
        id = parcel.readInt();
        text = parcel.readString();
        color = parcel.readInt();
        return true;
    }

    public int getId() {
        return id;
    }

    public String getText() {
        return text;
    }

    public int getColor() {
        return color;
    }

    @Override
    public boolean hasFileDescriptor() {
        return false;
    }

    /**
     * Builder.
     *
     * @since 2021-06-29
     */
    public static class Builder {
        private int mId;
        private String mText;
        private int mColor;

        private Builder() {
        }

        /**
         * 设置id
         *
         * @param id int
         * @return Builder
         */
        public Builder id(int id) {
            this.mId = id;
            return this;
        }

        /**
         * 设置text
         *
         * @param text String
         * @return Builder
         */
        public Builder text(String text) {
            this.mText = text;
            return this;
        }

        /**
         * 设置color
         *
         * @param color int
         * @return Builder
         */
        public Builder color(int color) {
            this.mColor = color;
            return this;
        }

        /**
         * build
         *
         * @return Thing
         */
        public Thing build() {
            return new Thing(mId, mText, mColor);
        }
    }
}
